package com.caocaog.market.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import javax.validation.constraints.AssertFalse;
import javax.validation.constraints.DecimalMin;
import java.io.Serializable;
import java.math.BigDecimal;

/**
 * 公里价格
 *
 * @author chechen
 * @date 2021-11-30
 */
@Data
@TableName("mk_shop_kilometer_price")
@Accessors(chain = true)
@NoArgsConstructor
@ApiModel(value = "mk_shop_kilometer_price对象", description = "公里价格")
public class ShopKilometerPrice implements Serializable {
    private static final long serialVersionUID = 1L;

    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "ID")
    private Long id;

    @DecimalMin(value = "0", message = "开始公里不能小于0")
    @ApiModelProperty(value = "开始公里")
    private BigDecimal kilometerStr;

    @DecimalMin(value = "0", message = "结束公里不能小于0")
    @ApiModelProperty(value = "结束公里")
    private BigDecimal kilometerEnd;

    @DecimalMin(value = "0", message = "每公里价格不能小于0")
    @ApiModelProperty(value = "每公里价格")
    private BigDecimal price;

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        ShopKilometerPrice that = (ShopKilometerPrice) o;
        return price.compareTo(that.getPrice()) == 0
                && kilometerStr.compareTo(that.getKilometerStr()) == 0
                && kilometerEnd.compareTo(that.getKilometerEnd()) == 0;
    }

    @Override
    public int hashCode() {
        return (kilometerStr.floatValue() + "_" + kilometerEnd.floatValue() + "_" + price.floatValue()).hashCode();
    }
}
